package com.dk.goodnight.api;

import com.dk.goodnight.utils.StringUtils;

public class Result<T> {

    private T data;

    private String msg;

    private int code;

    public Result(T data) {
        this.code = ErrorCodeEnum.SUCCESS.getCode();
        this.data = data;
    }

    public Result(T data, ErrorCodeEnum errorCodeEnum, String msg) {
        this.data = data;
        this.code = errorCodeEnum.getCode();
        if (StringUtils.isEmpty(msg)) {
            msg = "";
        }
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
